package com.xiaomaoguai.webkit.web.listener;

import java.io.File;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.xiaomaoguai.webkit.core.utils.XmgFileUtils;
import com.xiaomaoguai.webkit.web.XmgWebUtils;

/**
 * @Description :
 * @FileName: WebPropertyContextListener.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年5月8日 下午2:32:56
 * @Version:V1.00
 */
public class WebPropertyContextListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent event) {
		ServletContext context = event.getServletContext();
		context.log("第3加载的Listener");
		context.log("ctx =  " + event.getServletContext().getContextPath());
		XmgWebUtils.setWebAppRootSystemProperty(XmgWebUtils.WEB_ROOT_KEY, event.getServletContext());
		event.getServletContext().setAttribute("ctx", event.getServletContext().getContextPath());
		String userDir = event.getServletContext().getRealPath("") + File.separator + "WEB-INF" + File.separator;
		XmgFileUtils.setUserDir(userDir);
	}

	@Override
	public void contextDestroyed(ServletContextEvent event) {

	}

}
